﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class FormReservationsEnCours : Form
    {
        private BindingSource bindingSource = new BindingSource();
        private SqlDataAdapter dataAdapter = new SqlDataAdapter();

        public FormReservationsEnCours()
        {
            InitializeComponent();
        }

        private void FormReservationsEnCours_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = bindingSource;
            GetData("SELECT * FROM ReservationEnCours");
        }

        private void GetData(string selectCommand)
        {
            try
            {
                String connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename='C:\Users\Mathieu\Documents\Visual Studio 2010\Projects\pCamping\WindowsFormsApplication1\WindowsFormsApplication1\Database1.mdf';Integrated Security=True;Connect Timeout=30;User Instance=True";
                dataAdapter = new SqlDataAdapter(selectCommand, connectionString);
                SqlCommandBuilder commandbuilder = new SqlCommandBuilder(dataAdapter);
                DataTable table = new DataTable();
                table.Locale = System.Globalization.CultureInfo.InvariantCulture;
                dataAdapter.Fill(table);
                bindingSource.DataSource = table;

            //  dataGridView1.AutoResizeColumn(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
            }
            catch (SqlException e)
            {
                MessageBox.Show(e.Message);
            }
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
   
    }
}
